<?php
/**
 * 春哥团队（www.cgtblog.com） - 春哥多端多商户万能DIY商城系统
 * Copyright © 2024 春哥技术团队 保留所有权利
 * =========================================================

 * ----------------------------------------------
 * 您只能在商业授权范围内使用，不可二次转售、分发、分享、传播
 * 任何企业和个人不得对代码以任何目的任何形式的再发布
 * =========================================================
 */

// +----------------------------------------------------------------------
// | 会员等级
// +----------------------------------------------------------------------
namespace app\controller;
use think\facade\View;
use think\facade\Db;

class MemberLevel extends Common
{
    public function initialize(){
		parent::initialize();
		if(bid > 0) showmsg('无访问权限');
	}
	//列表
    public function index(){
		if(request()->isAjax()){
			$page = input('param.page');
			$limit = input('param.limit');
			if(input('param.field') && input('param.order')){
				$order = input('param.field').' '.input('param.order');
			}else{
				$order = 'sort,id';
			}
			$where = [['aid','=',aid]];
			$count = 0 + Db::name('member_level')->where($where)->count();
			$data = Db::name('member_level')->where($where)->page($page,$limit)->order($order)->select()->toArray();
			foreach($data as $k=>$v){
				$atj = array();
				if($v['can_apply']){
					//if($v['apply_ordercount'] > 0) $atj[]='订单满'.$v['apply_ordercount'].'个';
					if($v['apply_ordermoney'] > 0) $atj[]='订单金额满'.$v['apply_ordermoney'].'元';
					if($v['apply_rechargemoney'] > 0) $atj[]='充值金额满'.$v['apply_rechargemoney'].'元';
					if($atj){
						$data[$k]['applytj'] = implode(' 或 ',$atj);
					}else{
						$data[$k]['applytj'] = '无';
					}
				}else{
					$data[$k]['applytj'] = '不可申请';
				}
				if($v['can_up']){
					$tj = array();
					//if($v['up_ordercount'] > 0) $tj[]='订单满'.$v['up_ordercount'].'个';
					if($v['up_wxpaymoney'] > 0) $tj['up_wxpaymoney']='微信支付金额满'.$v['up_wxpaymoney'].'元';
					if($v['up_ordermoney'] > 0) $tj['up_ordermoney']='订单金额满'.$v['up_ordermoney'].'元';
					if($v['up_rechargemoney'] > 0) $tj['up_rechargemoney']='充值金额满'.$v['up_rechargemoney'].'元';
					if($v['up_fxordermoney'] > 0) $tj['up_fxordermoney']='分销订单满'.$v['up_fxordermoney'].'元';
					if($v['up_fxdowncount'] > 0) $tj['up_fxdowncount']='下级总人数满'.$v['up_fxdowncount'].'个';
                    if($v['up_fxdowncount_and'] > 0) $tj['up_fxdowncount_and']='下级总人数满'.$v['up_fxdowncount_and'].'个';
					if($v['up_proid'] > 0 && $v['up_pronum'] > 0) $tj['up_proid']='购买商品['.Db::name('shop_product')->where('id',$v['up_proid'])->value('name').']*'.$v['up_pronum'];
					if($v['up_getmembercard']==1) $tj[]='领取微信会员卡';
					if($tj){
					    $i = 1;
                        $aglevelList[$k]['uptj'] = '';
					    foreach($tj as $key => $item) {
					        if($i == 1) {
                                $data[$k]['uptj'] .= $item;
                            } else {
					            $realtion = ' 或 ';
					            if($v['up_fxorder_condition'] == 'and' && $key == 'up_fxordermoney') {
                                    $realtion = ' 且 ';
                                }
                                if($key == 'up_fxdowncount_and') {
                                    $realtion = ' 且 ';
                                }
                                if($v['up_buygoods_condition'] == 'and' && $key == 'up_proid') {
                                    $realtion = ' 且 ';
                                }
                                $data[$k]['uptj'] .= $realtion.$item;
                            }
                            $i++;
                        }
					}else{
						$data[$k]['uptj'] = '不自动升级';
					}
				}else{
					$data[$k]['uptj'] = '不自动升级';
					if($v['isdefault']){
						$data[$k]['uptj'] = '默认等级无需升级';
					}
				}
				if($v['can_agent']==1){
					$data[$k]['commission'] = $v['commission1'].($v['commissiontype']==1?'元':'%');
				}elseif($v['can_agent']==2){
					$data[$k]['commission'] = $v['commission1'].($v['commissiontype']==1?'元':'%').' / '.$v['commission2'].($v['commissiontype']==1?'元':'%');
				}elseif($v['can_agent']==3){
					$data[$k]['commission'] = $v['commission1'].($v['commissiontype']==1?'元':'%').' / '.$v['commission2'].($v['commissiontype']==1?'元':'%').' / '.$v['commission3'].($v['commissiontype']==1?'元':'%');
				}elseif($v['can_agent']==99){
                    $data[$k]['commission'] = '递归分销';
                }else{
					$data[$k]['commission'] = '无分销权限';
				}
				$cat = Db::name('member_level_category')->where('aid', aid)->where('id',$v['cid'])->find();
                $data[$k]['cat_name'] = $cat['name'];
                $data[$k]['defaultCat'] = $cat['isdefault'];
			}
			return json(['code'=>0,'msg'=>'查询成功','count'=>$count,'data'=>$data]);
		}

		$haslevel = Db::name('member_level')->where('aid',aid)->where('isdefault',1)->find();
		if(!$haslevel){
			Db::name('member_level')->insert(array('aid'=>aid,'isdefault'=>1,'name'=>'普通会员','icon'=>PRE_URL.'/static/imgsrc/level_1.png'));
		}
		return View::fetch();
	}
	//编辑
	public function edit(){
		if(input('param.id')){
			$info = Db::name('member_level')->where('aid',aid)->where('id',input('param.id/d'))->find();
            $info['up_give_score'] = dd_money_format($info['up_give_score'],$this->score_weishu);
			//if($info['islock'] == 1 && session('isunlock')!=1){
			//	showmsg('请先输入解锁密码');
			//}
            }else{
			$info = array('id'=>'','yxqdate'=>0);
			$info['sort'] = 1 + Db::name('member_level')->where('aid',aid)->max('sort');
			$level = 1 + Db::name('member_level')->where('aid',aid)->count();
			$info['icon'] = PRE_URL.'/static/imgsrc/level_'.$level.'.png';
		}
		if(!$info['apply_formdata']){
			$info['apply_formdata'] = json_encode([
				['key'=>'input','val1'=>'姓名','val2'=>'请填写姓名','val3'=>'1'],
				['key'=>'input','val1'=>'手机号','val2'=>'请填写手机号','val3'=>'1'],
			]);
		}
		View::assign('info',$info);
		View::assign('plug_businessqr', getcustom('plug_businessqr'));
        $catList = Db::name('member_level_category')->where('aid',aid)->select()->toArray();
        View::assign('catList',$catList);
        View::assign('isdefault_cat',true);
        $default_cat = collect($catList)->where('isdefault',1)->first();
        View::assign('default_cat',$default_cat);
        if($info['id'] && $default_cat && $info['cid'] != $default_cat['id']) {
            View::assign('isdefault_cat',false);
        }
		$sysset = Db::name('admin_set')->where('aid',aid)->find();
		View::assign('sysset',$sysset);

		
		if(false){}else{
			$teamfenhong_pingji = false;
		}
        //升级赠送优惠券
        View::assign('teamfenhong_pingji',$teamfenhong_pingji);
        if(getcustom('level_auto_down') || getcustom('member_level_down_commission')){
            //所有级别
            $all_level = Db::name('member_level')->where('aid',aid)->order('sort asc')->select()->toArray();
            View::assign('all_level',$all_level);
        }
        //薪资补贴
        //奖励上级佣金
        $default_cid = Db::name('member_level_category')->where('aid',aid)->where('isdefault', 1)->value('id');
        $default_cid = $default_cid ? $default_cid : 0;
        $levellist = Db::name('member_level')->where('aid',aid)->where('cid', $default_cid)->order('sort,id')->select()->toArray();
        View::assign('levellist',$levellist);
        $maidan_fenhong_new = 0;
        View::assign('maidan_fenhong_new',$maidan_fenhong_new);

		return View::fetch();
	}
	public function save(){
		$info = input('post.info/a');
		$datatype = input('post.datatype/a');
		$dataval1 = input('post.dataval1/a');
		$dataval2 = input('post.dataval2/a');
		$dataval3 = input('post.dataval3/a');
        $dhdata = array();
		foreach($datatype as $k=>$v){
			if($dataval3[$k]!=1) $dataval3[$k] = 0;
			$dhdata[] = array('key'=>$v,'val1'=>$dataval1[$k],'val2'=>$dataval2[$k],'val3'=>$dataval3[$k]);
		}
		$info['apply_formdata'] = json_encode($dhdata,JSON_UNESCAPED_UNICODE);

        $default_cid = Db::name('member_level_category')->where('aid',aid)->where('isdefault', 1)->value('id');
        $default_cid = $default_cid ? $default_cid : 0;
        if($info['cid'] > 0 && $info['cid'] != $default_cid) {
            //非默认分组不支持设置分销和优惠
            unset($info['discount']);
            $info['can_agent'] = 0;
        }
        if(empty($info['cid'])) $info['cid'] = $default_cid;

		//升级赠送优惠券
        //升级后脱离和升级后回归只能设置一个，否则矛盾
        if(!empty($info['up_change_pid']) && $info['up_change_pid']==1){
            $info['up_change_back'] = 0;
        }
        //薪资奖励
        //会员升级奖励不同会员等级的推荐佣金

       //升级赠送周期优惠券
		if($info['up_pro_extend_time']==1 && $info['up_pro_keep_time']==1){
            return json(['status'=>0,'msg'=>'复购累加有效期和复购保持等级有效期不可同时开启']);
        }

		if($info['id']){
			Db::name('member_level')->where('aid',aid)->where('id',$info['id'])->update($info);
			\app\common\System::plog('编辑会员等级'.$info['id']);
		}else{
			$info['aid'] = aid;
			$info['createtime'] = time();
			$id = Db::name('member_level')->insertGetId($info);
			\app\common\System::plog('添加会员等级'.$id);
		}
		return json(['status'=>1,'msg'=>'操作成功','url'=>(string)url('index')]);
	}
	//删除
	public function del(){
		$ids = input('post.ids/a');
		Db::name('member_level')->where('aid',aid)->where('id','in',$ids)->delete();
		\app\common\System::plog('删除会员等级'.implode(',',$ids));
		return json(['status'=>1,'msg'=>'删除成功']);
	}
	//锁定
	public function dolock(){
		if(session('IS_ADMIN') == 0) return json(['status'=>1,'msg'=>'无权限操作']);
		$id = input('post.id/d');
		$st = input('post.st/d');
		Db::name('member_level')->where('aid',aid)->where('id',$id)->update(['islock'=>$st]);
		return json(['status'=>1,'msg'=>'操作成功']);
	}
	//申请记录
	public function applyorder(){
		$levelList = Db::name('member_level')->where('aid',aid)->select()->toArray();
		$levelArr = array();
		foreach($levelList as $v){
			$levelArr[$v['id']] = [
				'name'=>$v['name'],
				'areafenhong'=>$v['areafenhong'],
				'field_list'=>json_decode($v['field_list'],true),
				'is_agree'=>$v['is_agree']??0,
			];
		}
		if(request()->isAjax()){
			$page = input('param.page');
			$limit = input('param.limit');
			if(input('param.field') && input('param.order')){
				$order = input('param.field').' '.input('param.order');
			}else{
				$order = 'id desc';
			}
			$where = [];
			$where[] = ['vo.aid','=',aid];
            if(input('param.mid')) $where[] = ['m.id','=',input('param.mid')];
			if(input('param.pid')) $where[] = ['m.pid','=',input('param.pid')];
			if(input('param.nickname')) $where[] = ['m.nickname','like','%'.input('param.nickname').'%'];
			if(input('param.realname')) $where[] = ['m.realname','like','%'.input('param.realname').'%'];
			if(input('param.formx')) $where[] = ['vo.form0|vo.form1|vo.form2|vo.form3|vo.form4|vo.form5|vo.form6|vo.form7|vo.form8|vo.form9|vo.form10|vo.form11|vo.form12|vo.form13|vo.form14|vo.form15|vo.form16|vo.form17|vo.form18|vo.form19|vo.form20|vo.areafenhong_province|vo.areafenhong_city|vo.areafenhong_area','like','%'.input('param.formx').'%'];
			if(input('param.ctime')){
				$ctime = explode(' ~ ',$_GET['ctime']);
				$where[] = ['vo.createtime','>=',strtotime($ctime[0])];
				$where[] = ['vo.createtime','<',strtotime($ctime[1]) + 86400];
			}
			$count = 0 + Db::name('member_levelup_order')->alias('vo')->join('member m','vo.mid = m.id')->where($where)->count();
			$data = Db::name('member_levelup_order')->alias('vo')->join('member m','vo.mid = m.id')->field('vo.*,m.nickname,m.realname')->where($where)->page($page,$limit)->order($order)->select()->toArray();
			foreach($data as $k=>$v){
				$member = Db::name('member')->where('id',$v['mid'])->find();
				if(!$member){
					$data[$k]['nickname'] = '未找到该'.t('会员');
					$data[$k]['headimg'] = '';
				}else{
					$data[$k]['nickname'] = $member['nickname'];
					$data[$k]['headimg'] = $member['headimg'];
				}
				if($v['pid']) {
                    $parent = Db::name('member')->where('id', $v['pid'])->find();
                }elseif($member['pid']){
                    $parent = Db::name('member')->where('id',$member['pid'])->find();
                }else{
                    $parent = [];
                }
				if(!$parent){
					$data[$k]['pnickname'] = '';
					$data[$k]['pheadimg'] = '';
				}else{
					$data[$k]['pid'] = $parent['id'];
					$data[$k]['pnickname'] = $parent['nickname'];
					$data[$k]['pheadimg'] = $parent['headimg'];
				}
				$data[$k]['levelname'] = $v['beforelevelid'] ? $levelArr[$v['beforelevelid']]['name'] : $levelArr[$member['levelid']]['name'];
				$data[$k]['applylevelname'] = $levelArr[$v['levelid']]['name'];
				$formdata = [];
				for($i=0;$i<=20;$i++){
					if($v['form'.$i]){
						$formArr = explode('^_^',$v['form'.$i]);
						if($formArr[2] == 'upload'){
							$formArr[1] = '<img src="'.$formArr[1].'" style="width:60px;height:auto" onclick="preview(this)">';
						}
						$formdata[] = $formArr[0] . '：'.$formArr[1];
					}
				}
				if($levelArr[$v['levelid']]['areafenhong'] ==1){
					$formdata[] = '代理区域：'.$v['areafenhong_province'];
				}
				if($levelArr[$v['levelid']]['areafenhong'] ==2){
					$formdata[] = '代理区域：'.$v['areafenhong_province'].','.$v['areafenhong_city'];
				}
				if($levelArr[$v['levelid']]['areafenhong'] ==3){
					$formdata[] = '代理区域：'.$v['areafenhong_province'].','.$v['areafenhong_city'].','.$v['areafenhong_area'];
				}
				if($levelArr[$v['levelid']]['areafenhong'] ==10){
					$formdata[] = '代理区域：'.$v['areafenhong_largearea'];
				}
				$data[$k]['formdata'] = implode('<br>',$formdata);
				}
			return json(['code'=>0,'msg'=>'查询成功','count'=>$count,'data'=>$data]);
		}
		View::assign('levelArr',$levelArr);
		return View::fetch();
	}
	//申请审核
	public function applyshenhe(){
		$id = input('post.id/d');
		$st = input('post.st/d');
		$order = Db::name('member_levelup_order')->where('aid',aid)->where('id',$id)->find();
		Db::name('member_levelup_order')->where('aid',aid)->where('id',$id)->update(['status'=>$st]);
		if($st ==2){
            Db::name('member_levelup_order')->where('aid',aid)->where('id',$id)->update(['levelup_time'=>time()]);
			$newlv = Db::name('member_level')->where('aid',aid)->where('id',$order['levelid'])->find();
			if($newlv['yxqdate'] > 0){
				$levelendtime = strtotime(date('Y-m-d')) + 86400 + 86400 * $newlv['yxqdate'];
			}else{
				$levelendtime = 0;
			}
            //判断是否默认分组
			if($newlv['cid'] > 0)
            $is_default = Db::name('member_level_category')->where('id', $newlv['cid'])->value('isdefault');
            if($is_default || $newlv['cid'] == 0) {
                Db::name('member')->where('id',$order['mid'])->update(['levelid'=>$newlv['id'],'levelendtime'=>$levelendtime,'levelstarttime'=>time()]);
                if($order['status']==1 && $newlv['apply_payfenxiao'] == 1 && $order['totalprice'] > 0){ //升级费用参与分销及分红
                    \app\common\Common::applypayfenxiao(aid,$order['id']);
                }

                //更新代理区域
                if($newlv['areafenhong']==1){
                    Db::name('member')->where('aid',aid)->where('id',$order['mid'])->update(['areafenhong_province'=>$order['areafenhong_province']]);
                }elseif($newlv['areafenhong']==2){
                    Db::name('member')->where('aid',aid)->where('id',$order['mid'])->update(['areafenhong_province'=>$order['areafenhong_province'],'areafenhong_city'=>$order['areafenhong_city']]);
                }elseif($newlv['areafenhong']==3){
                    Db::name('member')->where('aid',aid)->where('id',$order['mid'])->update(['areafenhong_province'=>$order['areafenhong_province'],'areafenhong_city'=>$order['areafenhong_city'],'areafenhong_area'=>$order['areafenhong_area']]);
                }elseif($newlv['areafenhong']==10){
                    Db::name('member')->where('aid',aid)->where('id',$order['mid'])->update(['areafenhong_largearea'=>$order['areafenhong_largearea']]);
                }
            } else {
                }

            \app\common\Wechat::updatemembercard(aid,$order['mid']);

            //赠送积分
            if($newlv['up_give_score'] > 0) {
                \app\common\Member::addscore(aid,$order['mid'],$newlv['up_give_score'],'升级奖励');
            }

            //奖励佣金
            if($newlv['up_give_commission'] > 0) {
                \app\common\Member::addcommission(aid,$order['mid'],0,$newlv['up_give_commission'],'升级奖励');
            }

            //奖励余额
            if($newlv['up_give_money'] > 0) {
                \app\common\Member::addmoney(aid,$order['mid'],$newlv['up_give_money'],'升级奖励');
            }

            //赠送上级佣金
            if ($newlv['up_give_parent_money'] > 0) {
                $pid = Db::name('member')->where('aid', aid)->where('id', $order['mid'])->value('pid');
                if($pid > 0) \app\common\Member::addcommission(aid, $pid, $order['mid'], $newlv['up_give_parent_money'], '直推奖');
            }

			//升级赠送优惠券
            $tmplcontent = [];
			$tmplcontent['first'] = '恭喜您成功升级为'.$newlv['name'];
			$tmplcontent['remark'] = '点击进入查看~';
			$tmplcontent['keyword1'] = $newlv['name']; //会员等级
			$tmplcontent['keyword2'] = '已生效';//审核状态
			\app\common\Wechat::sendtmpl(aid,$order['mid'],'tmpl_uplv',$tmplcontent,m_url('pages/my/usercenter'));
		}
		\app\common\System::plog('审核会员升级申请记录'.$id);
		return json(['status'=>1,'msg'=>'操作成功']);
	}
	
	//审核删除
	public function applydel(){
		$ids = input('post.ids/a');
		Db::name('member_levelup_order')->where('aid',aid)->where('id','in',$ids)->delete();
		\app\common\System::plog('删除会员升级申请记录'.implode(',',$ids));
		return json(['status'=>1,'msg'=>'删除成功']);
	}
    public function chooselevel(){
        if(request()->isPost()){
            $id = input('param.id/d');
            $coupon = Db::name('member_level')->where('aid',aid)->where('id',$id)->find();
            return json(['status'=>1,'data'=>$coupon]);
        }
        return View::fetch();
    }

    public function bgset(){
        }

    public function applyexcel(){
        $levelList = Db::name('member_level')->where('aid',aid)->select()->toArray();
        $levelArr = array();
        foreach($levelList as $v){
            $levelArr[$v['id']] = [
                'name'=>$v['name'],
                'areafenhong'=>$v['areafenhong'],
                'field_list'=>json_decode($v['field_list'],true),
            ];
        }
        if(input('param.field') && input('param.order')){
            $order = input('param.field').' '.input('param.order');
        }else{
            $order = 'id desc';
        }
        $where = [];
        $where[] = ['vo.aid','=',aid];
        if(input('param.mid')) $where[] = ['m.id','=',input('param.mid')];
        if(input('param.pid')) $where[] = ['m.pid','=',input('param.pid')];
        if(input('param.nickname')) $where[] = ['m.nickname','like','%'.input('param.nickname').'%'];
        if(input('param.realname')) $where[] = ['m.realname','like','%'.input('param.realname').'%'];
        if(input('param.formx')) $where[] = ['vo.form0|vo.form1|vo.form2|vo.form3|vo.form4|vo.form5|vo.form6|vo.form7|vo.form8|vo.form9|vo.form10|vo.form11|vo.form12|vo.form13|vo.form14|vo.form15|vo.form16|vo.form17|vo.form18|vo.form19|vo.form20|vo.areafenhong_province|vo.areafenhong_city|vo.areafenhong_area','like','%'.input('param.formx').'%'];
        if(input('param.ctime')){
            $ctime = explode(' ~ ',$_GET['ctime']);
            $where[] = ['vo.createtime','>=',strtotime($ctime[0])];
            $where[] = ['vo.createtime','<',strtotime($ctime[1]) + 86400];
        }
        $data = Db::name('member_levelup_order')->alias('vo')->join('member m','vo.mid = m.id')->field('vo.*,m.nickname,m.realname')->where($where)->order($order)->select()->toArray();
        $statusArr = [
            0=>'未支付',
            1=>'待审核',
            2=>'已通过',
            3=>'已驳回',
        ];
        foreach($data as $k=>$v){
            $member = Db::name('member')->where('id',$v['mid'])->find();
            if(!$member){
                $data[$k]['nickname'] = '未找到该'.t('会员');
                $data[$k]['headimg'] = '';
            }else{
                $data[$k]['nickname'] = $member['nickname'];
                $data[$k]['headimg'] = $member['headimg'];
            }
            if($member['pid']){
                $parent = Db::name('member')->where('id',$member['pid'])->find();
            }else{
                $parent = [];
            }
            if(!$parent){
                $data[$k]['pnickname'] = '';
                $data[$k]['pheadimg'] = '';
            }else{
                $data[$k]['pid'] = $parent['id'];
                $data[$k]['pnickname'] = $parent['nickname'];
                $data[$k]['pheadimg'] = $parent['headimg'];
            }
            $data[$k]['levelname'] = $v['beforelevelid'] ? $levelArr[$v['beforelevelid']]['name'] : $levelArr[$member['levelid']]['name'];
            $data[$k]['applylevelname'] = $levelArr[$v['levelid']]['name'];
            $formdata = [];
            for($i=0;$i<=20;$i++){
                if($v['form'.$i]){
                    $formArr = explode('^_^',$v['form'.$i]);
                    if($formArr[2] == 'upload'){
                        $formArr[1] = '<img src="'.$formArr[1].'" style="width:60px;height:auto" onclick="preview(this)">';
                    }
                    $formdata[] = $formArr[0] . '：'.$formArr[1];
                }
            }
            if($levelArr[$v['levelid']]['areafenhong'] ==1){
                $formdata[] = '代理区域：'.$v['areafenhong_province'];
            }
            if($levelArr[$v['levelid']]['areafenhong'] ==2){
                $formdata[] = '代理区域：'.$v['areafenhong_province'].','.$v['areafenhong_city'];
            }
            if($levelArr[$v['levelid']]['areafenhong'] ==3){
                $formdata[] = '代理区域：'.$v['areafenhong_province'].','.$v['areafenhong_city'].','.$v['areafenhong_area'];
            }
            if($levelArr[$v['levelid']]['areafenhong'] ==10){
                $formdata[] = '代理区域：'.$v['areafenhong_largearea'];
            }
            $data[$k]['formdata'] = implode('\n\tab',$formdata);
            $data[$k]['status_txt'] = $statusArr[$v['status']]??'';
        }

        $title = array();
        $title[] = 'ID';
        $title[] = '昵称ID';
        $title[] = '推荐人';
        $title[] = '当前等级';
        $title[] = '申请等级';
        $title[] = '申请资料';
        $title[] = '金额';
        $title[] = '状态';
        $title[] = '申请时间';
        $dataXlx = array();
        foreach($data as $v){
            $tdata = array();
            $tdata[] = $v['id'];
            $tdata[] = $v['nickname'].'('.$v['mid'].')';
            $tdata[] = $v['pnickname'].'('.$v['pid'].')';
            $tdata[] = $v['levelname'];
            $tdata[] = $v['applylevelname'];
            $tdata[] = $v['formdata'];
            $tdata[] = $v['totalprice'];
            $tdata[] = $v['status_txt'];
            $tdata[] = date('Y-m-d H:i:s',$v['createtime']);
            $dataXlx[] = $tdata;
        }
        $this->export_excel($title,$dataXlx);
    }
	
	//转赠订单列表
    public function saleorder(){
		}
		
	//转赠订单删除
	public function saleorderdel(){
		}
}
